#pragma once
#include <iostream>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
using namespace std;

const string gpath = "./fifo";
const int gmode = 0600;
const int gdefulted = -1;
const int gsize = 1024;
const int READFLAG = O_RDONLY;
const int WRITEFLAG = O_WRONLY;

int OpenPipe(int flag)
{
    //以写的方式打开管道
    int fd = open(gpath.c_str(),flag);
    if(fd < 0)//打开文件失败
    {
        cerr<<"open error"<<endl;
        return false;
    }
    return fd;
}

void ClosePipeHelper(int fd)
{
    //判断fd是否合法
    if(fd >= 0) close(fd);
}
